package code.structure.module.scene.view.iso
{
	import code.untils.SceneConfig;
	
	import flash.display.BitmapData;
	import flash.geom.Vector3D;

	/**
	 * 门的零部件 （暂未两部分） 
	 * @author Yuri
	 * 
	 */
	public class DoorComponentIsoObject extends DecorateIsoObject
	{
		/**
		 *是否可以通行 
		 */
		private var _isWalkAble:Boolean;
		private var _parentDoor:DoorIsoObject;
		
		/**
		 *偏移的格子索引 
		 */
		private var _offsetGridIndex:int=0;
		public function DoorComponentIsoObject(offsetGridIndex:int=0)
		{
			super();
			mouseEnabled = false;
			mouseMoveEnabled = false;
			clickEnabled = false;
			_offsetGridIndex = offsetGridIndex;
		}
		
		/**
		 *设置素材信息 
		 * @param arr
		 * 
		 */
		public function set materialInfo(arr:Array):void{
			createBody();
			var bitmapInfo:Array =  arr[0] as Array;
			bitmap.bitmapData = bitmapInfo[0] as BitmapData;
			bitmap.x = arr[1] - _offsetGridIndex*SceneConfig.WORLD_GRID_SIZE;
			bitmap.y = arr[2] -  _offsetGridIndex*SceneConfig.WORLD_GRID_SIZE/2;
		}

		override public function set direction(value:int):void{
//			if(direction == value) return;
			_direction = value;
				if(direction==1){
					_mainBitMapContainer.scaleX = 1;
				}else{
					_mainBitMapContainer.scaleX = -1;
				}
			
			var p:Vector3D =  _parentDoor.position3D.clone();
			if(value==1){
				p.x += _offsetGridIndex*SceneConfig.WORLD_GRID_SIZE;
			}else{
				p.z += _offsetGridIndex*SceneConfig.WORLD_GRID_SIZE;
			}
			this.position3D = p;
		}
		
		/**
		 *是否可以通行 
		 */
		public function get isWalkAble():Boolean
		{
			return _isWalkAble;
		}

		/**
		 * @private
		 */
		public function set isWalkAble(value:Boolean):void
		{
			_isWalkAble = value;
		}

		/**
		 *门主体 
		 */
		public function set parentDoor(value:DoorIsoObject):void
		{
			_parentDoor = value;
		}


	}
}